<?php  
function error($info,$url = 'user_info.php?op=1')
{
	echo "<h3>$info</h3>";
	header('Refresh:2; url=' . $url);
}

function success($info,$url = 'index.php')
{
	echo "<h3>$info</h3>";
	header('Refresh:2; url=' . $url);
}

function input($name,$default = '')
{
	$value = $default;
	if (isset($_POST[$name])) {
		if (gettype($_POST[$name]) == 'string') {
			$value = htmlspecialchars($_POST[$name]);
		}else{
			$value = $_POST[$name];
		}
	}
	return $value;
}

/**
 *对数组中年龄进行比较
 *@param $emp1,emp2 数组中要比较的对象
 *@return 返回比较结果
 */
function compareByAge($emp1,$emp2)
{
	return ($emp1['age'] - $emp2['age']);
}


/**
 *对数组中薪水进行比较
 *@param $emp1,emp2 数组中要比较的对象
 *@return 返回比较结果
 */
function compareBySalary($emp1,$emp2)
{
	return ($emp1['salary'] - $emp2['salary']);
}

/**
 *对数组中薪水进行比较
 *@param $emp1,emp2 数组中要比较的对象
 *@return 返回比较结果
 */
function compareById($emp1,$emp2)
{
	return ($emp1['id'] - $emp2['id']);
}

/**
 *对数组中name进行比较
 *@param $emp1,emp2 数组中要比较的对象
 *@return 返回比较结果
 */
function compareByName($emp1,$emp2)
{
	return strcmp($emp1['user_name'], $emp2['user_name']);
}
?>